package com.kevis.zhunblog.service.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kevis.zhunblog.core.dto.PageDomain;
import com.kevis.zhunblog.core.entities.AdminEntity;
import com.kevis.zhunblog.mapper.AdminMapper;
import com.kevis.zhunblog.service.AdminService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 *
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, AdminEntity>
    implements AdminService{

    /**
     * Describe: 查询用户数据
     * Param: QueryRoleParam
     * Return: 操作结果
     */
    @Override
    public List<AdminEntity> list(AdminEntity param) {
        LambdaQueryChainWrapper<AdminEntity> wrapper = lambdaQuery();
        if (param != null) {
            if (StringUtils.hasLength(param.getAdminName())) {
                wrapper.eq(AdminEntity::getAdminName, param.getAdminName());
            }
        }
        return wrapper.list();
    }

    /**
     * Describe: 查询用户数据 分1页
     * Param: QueryRoleParam
     * Return: 操作结果
     */
    @Override
    public PageInfo<AdminEntity> page(AdminEntity param, PageDomain pageDomain) {
        PageHelper.startPage(pageDomain.getPage(), pageDomain.getLimit());
        List<AdminEntity> list = list(param);
        return new PageInfo<>(list);
    }
}




